home *** CD-ROM | disk | FTP | other *** search
- // Ressort - version 1.2
-
- // Ce script relie les calques 1 et 2 par un ressort. Le calque 1 conserve son mouvement
- // d'origine et le calque 2 se dΘplace comme s'il lui Θtait attachΘ au moyen d'un ressort.
-
- // CALQUE PROPRIETE DIMENSION
- // ------- ---------- ----------
- // 1: Calque en mouvement indiffΘrent indiffΘrent
- // 2: Calque attachΘ par un ressort indiffΘrent indiffΘrent
-
-
- if (time() == start_time) {
- rest_length = 10; // Longueur du ressort au repos, en pixels
- damp = 0.95; // Frottements (0 = infinis, 1 = nuls)
-
- p1 = value(pop_layer(1), position);
- p2 = value(pop_layer(2), position);
-
- last_p1 = tmap(time() - step_time, value(pop_layer(1), position));
- last_p2 = tmap(time() - step_time, value(pop_layer(2), position));
-
- v1 = (p1 - last_p1);
- v2 = (p2 - last_p2);
- } else {
- p1 = value(pop_layer(1), position);
-
- delta = p2 - p1;
- n_delta = normalize(delta);
-
- a = 2 * n_delta * (length(delta) - rest_length) * step_time;
-
- v2 = (v2 - a) * damp;
- v1 = (v1 + a) * damp;
-
- p1 = p1 + v1;
- p2 = p2 + v2;
- }
- value(pop_layer(2), position) = p2;
-
-